<!-- 系统日志-->
<template>
  <div>
    <a-card id="a" :bordered="false">
      <!-- tab 切换日志 start -->
      <a-tabs @change="handleTab">
        <a-tab-pane :tab="list.text" v-for="(list, index) in statusList" :key="index">
          <SystemLogList :activeIndex="statusIndex" :no="index"/>
        </a-tab-pane>
      </a-tabs>
      <!-- tab 切换日志  end -->
    </a-card>
  </div>
</template>

<script>
import SystemLogList from './components/System-Log-List'
import { mapState } from 'vuex'

export default {
  data () {
    return {
      statusIndex: 1,
      statusList: [
        // { status: 1, text: '用户操作日志' },
        // { status: 2, text: '权限变更日志' },
        { status: 3, text: this.$t('all.autotext594') }
      ]
    }
  },
  computed: {
    ...mapState({
      // 动态主路由
      mainMenu: state => state.permission.addRouters
    })
  },
  components: {
    SystemLogList
  },
  mounted () {
    // this.fetchList()
    this.showDynamicTitle()
  },
  methods: {
    // 用于切换状态的
    handleTab (key) {
      this.statusIndex = parseInt(key) + 1
    },
    // 动态改变tab栏名称
    showDynamicTitle () {
      const target = this.mainMenu.find(item => item.path === '/')
      const dynamicTitle = target.children.find(item => item.name === 'SystemLog').meta.title
      this.statusList.forEach(item => {
        if (item.status === 3) {
          item.text = dynamicTitle
        }
      })
    }
  }
}
</script>
